package uk.ac.aber.Blockmation;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTextArea;

/**
 * Dialog to show a block of text to the user about the program
 * @author alex
 */
public class AboutDialog extends JDialog implements ActionListener {
    
    private final String aboutText = "" +
            "********* GIFted Blockmation by T.A.Z.A *********\n\n" +
            "Project Authors - Tom (thm7@aber.ac.uk)\n" +
            "                  Aron (af7@aber.ac.uk)\n" +
            "                  Zuza (zzk7@aber.ac.uk)\n" +
            "                  Alex (axj7@aber.ac.uk)\n" +
            "\n" +
            "Project Description - \"a small ‘animation suite’ so that users " + 
            "can build cartoons (which are made up of frames) and then see " +
            "how they look when they run. The frames are made of little" +
            "blocks – squares of colour.\"" +
            "\n\n" +
            "Acknowledgment to Kevin Weiner, FM Software for the GIF file" +
            "format encoder/decoder library, free to use, from " +
            "http://www.fmsware.com/stuff/gif.html" +
            "\n\n" +
            "This program took 158 revisions to complete to this standard!";
    
    public AboutDialog() {
        this.setModal(false);
        this.setTitle("About this Program");
        this.setLocationRelativeTo(null);
        this.setResizable(false);
        
        JPanel dialogPanel = new JPanel();
        dialogPanel.setLayout(new BoxLayout(dialogPanel, BoxLayout.Y_AXIS));
        
        JTextArea textArea = new JTextArea(aboutText);
        textArea.setFont(new Font("Monospaced",0,14));
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.setEditable(false);
        textArea.setBackground(dialogPanel.getBackground());
        textArea.setSize(400,200);

        
        // Go Back Button
        JButton goBackButton = new JButton("Go Back");
        goBackButton.addActionListener(this);
        
        dialogPanel.add(textArea);
        dialogPanel.add(goBackButton);
        
        this.getContentPane().add(dialogPanel);
        
        this.pack();
        this.setVisible(true);
    }
    
    public void actionPerformed(ActionEvent e) {
        
        String actionCommand = e.getActionCommand();
        
        if (actionCommand.equals("Go Back")) {
            this.setVisible(false);
            this.dispose();
        }
        else {
            System.err.println("Error! Unexpected ActionCommand.");
	}
        
    }

}
